<template>
	<view class="tab_bar">
		<view class="tabbarBox"
			v-if="selectIndex!='/pages/shoppingmal/index'&&selectIndex!='/pages/shoppingmal/shangcheng'">
			<view class="handleBox" v-for="(item,index) in tabBarList" :key="index">
				<view class="menuBox" @click="goPages(item.pagePath)">
					<image v-if="item.pagePath==selectIndex" :src="item.selectedIconPath" class="img"></image>
					<image v-else class="img" :src="item.iconPath"></image>
					<text :class="item.pagePath==selectIndex?'TextColor':'Text'">{{item.text}}</text>
				</view>
			</view>
		</view>
		<view class="tabbarBox" v-else>
			<view class="handleBox" v-for="(item,index) in tabBarList1" :key="index">
				<view class="menuBox" @click="goPages(item.pagePath)">
					<image v-if="item.pagePath==selectIndex" :src="item.selectedIconPath" class="img"></image>
					<image v-else class="img" :src="item.iconPath"></image>
					<text :class="item.pagePath==selectIndex?'TextColor':'Text'">{{item.text}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		_static
	} from '@/ulm/utils/url.js'
	export default {
		props: {
			page: {
				type: String,
				default: "homeIndex",
			}
		},
		watch: {
			page: {
				handler(value) {
					this.selectIndex = value;

				},
				immediate: true,
				deep: true
			}
		},
		data() {
			return {
				selectIndex: "",
				tabBarList: [{
						"text": "首页",
						"pagePath": "/pages/index/index",
						"iconPath": "/static/images/Frame@2x(2)(1).png",
						"selectedIconPath": _static('/images/tabbar/Frame@2x(1).png')
					},
					{
						"text": "健康科普",
						"pagePath": "/pages/jiankang/index",
						"iconPath": _static('/images/tabbar/Frame@2x(2).png'),
						"selectedIconPath": _static('/images/tabbar/Frame@2x(5).png')
					}, {
						"text": "待办提醒",
						"pagePath": "/pages/daiban/index",
						"iconPath": _static('/images/tabbar/Frame@2x(3).png'),
						"selectedIconPath": _static('/images/tabbar/Frame@2x(6).png')
					}, {
						"text": "我的",
						"pagePath": "/pages/me/index",
						"iconPath": _static('/images/tabbar/Frame@2x(4).png'),
						"selectedIconPath": _static('/images/tabbar/Frame@2x(7).png')
					}
				],
				tabBarList1: [{
						"text": "商城",
						"pagePath": "/pages/shoppingmal/shangcheng",
						"iconPath": _static('/images/Frame@2x(41).png'),
						"selectedIconPath": _static('/images/Frame@2x(38).png')
					},
					{
						"text": "租赁",
						"pagePath": "/pages/shoppingmal/index",
						"iconPath": _static('/images/Frame@2x(39).png'),
						"selectedIconPath": _static('/images/Frame@2x(40).png')
					}
				],
			}

		},
		//uniapp子组件不支持应用生命周期，所以只能用vue生命周期
		created() {

		},
		methods: {

			//进入tabble页
			goPages(pageIndex) {
				uni.switchTab({
					url: pageIndex
				})
			},

		},
	}
</script>
<style lang="scss">
	.tab_bar {
		width: 100vw;
		position: fixed;
		bottom: 0rpx;
		overflow: hidden;
		z-index: 9999;
		/* 模糊大小就是靠的blur这个函数中的数值大小 */
		backdrop-filter: blur(10px);
		box-shadow: 0rpx -4rpx 8rpx 0rpx rgba(0, 0, 0, 0.02);
		background: #fff;

		.tabbarBox {
			display: flex;
			justify-content: space-evenly;
			margin-bottom: 10rpx;
			margin-top: 10rpx;

			.handleBox {
				width: 20vw;
				height: 110rpx;


				.menuBox {
					padding: 0rpx 20rpx;
					width: 120rpx;
					height: 98%;
					text-align: center;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					.img {
						width: 50rpx;
						height: 50rpx;
					}
				}
			}
		}
	}

	.Text {
		font-size: 24rpx;
		font-family: Cochin, serif;
		color: #4E5969;
		margin-top: 10rpx;
	}

	.TextColor {
		color: #1D2129;
		margin-top: 10rpx;
		font-size: 24rpx;
	}
</style>